/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.factory;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FileDialog;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.MenuItem;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowListener;
import java.util.Vector;

import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JProgressBar;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;

import com.ruipengkj.component.RPJButton;
import com.ruipengkj.component.RPToolBarJButton;
import com.ruipengkj.component.jtable.RPTable;

public class UIFactory {

	private static UIFactory instance;//当前工厂的一个实例
	//私有的构造器
	private UIFactory(){
		
	}
	//获得当前工厂的实例
	public static UIFactory getInstance(){
		if(instance==null){
			synchronized("key1"){
				instance=new UIFactory();
			}
		}
		return instance;
	}
 
	//产生一个标签
	public JLabel createJLabel(String text){
		JLabel l=new JLabel(text);
		return l;
	}
	//产生一个标签
		public JLabel createJLabel(String text, boolean isOpaque){
			JLabel l=new JLabel(text);
			l.setOpaque(isOpaque);
			return l;
		}
	//产生一个标签,带颜色，对齐方式
	public JLabel createJLabel(String text, Color fgColor, int horizontalAlignment){
		JLabel l=new JLabel(text, horizontalAlignment);
		l.setForeground(fgColor);
		return l;
	}
	//产生一个带图标的标签
	public JLabel createJLabel(String text,Icon icon){
		JLabel l=new JLabel(text);
		l.setIcon(icon);
		return l;
	}
	//产生一个带图标和鼠标监听器的的标签
	public JLabel createJLabel(String text,Icon icon,int horizontal,Font font,MouseListener ml,int width,int height,boolean isOpaque,Color bgColor,Border border){
		JLabel l=new JLabel(text,horizontal);
		l.setIcon(icon);
		l.addMouseListener(ml);
		l.setFont(font);
		l.setMaximumSize(new Dimension(width, height));
		l.setMinimumSize(new Dimension(width, height));
		l.setSize(width, height);
		l.setOpaque(isOpaque);
		l.setBackground(bgColor);
		l.setBorder(border);
		return l;
	}
	
	//专门产生按钮，而且添加快捷键      文本显示  命令  按键   辅助键  触发范围  监听器  是否显焦
	public JButton createJButton(String text,int mn,String command,ImageIcon icon,int key_keyEvent,int input_inputEvent,int when_invoke_jComponent,ActionListener al,boolean isFocus){
		JButton button=new JButton(text,icon);
		//这里默认会是alt+'mn'
		button.setMnemonic(mn);//设置辅助键
		button.setActionCommand(command);//设置动作
		button.addActionListener(al);
		KeyStroke stroke=KeyStroke.getKeyStroke(key_keyEvent,input_inputEvent,isFocus);
		button.registerKeyboardAction(al,command,stroke,when_invoke_jComponent);
		button.setFocusable(isFocus);
		return button;
	}
	//专门产生按钮                     文本显示  命令  监听器  是否显焦
	public JButton createJButton(ImageIcon icon,ActionListener al,boolean isContent, boolean isFocus){
		JButton button=new JButton("",icon);
		button.addActionListener(al);//添加事件监听
		button.setContentAreaFilled(isContent);
		button.setFocusPainted(isFocus);
		button.setBorder(null);
		return button;
	}
	
	//专门产生按钮                     文本显示  命令  监听器  是否显焦
	public JButton createJButton(String text,String command,ImageIcon icon,ActionListener al,boolean isFocus){
		JButton button=new JButton(text,icon);
		button.setActionCommand(command);//设置动作
		button.addActionListener(al);//添加事件监听
		button.setFocusable(isFocus);
		return button;
	}
	//专门产生按钮，而且添加快捷键      文本显示  命令  按键   辅助键  触发范围  监听器  是否显焦
	public JButton createJButton(String text,int mn,String command,ImageIcon icon,int width,int height,int key_keyEvent,int input_inputEvent,int when_invoke_jComponent,ActionListener al,boolean isFocus){
		JButton button=new JButton(text,icon);
		//这里默认会是alt+'mn'
		button.setMnemonic(mn);//设置辅助键
		button.setActionCommand(command);//设置动作
		button.setPreferredSize(new Dimension(width,height));
		button.addActionListener(al);
		KeyStroke stroke=KeyStroke.getKeyStroke(key_keyEvent,input_inputEvent,isFocus);
		button.registerKeyboardAction(al,command,stroke,when_invoke_jComponent);
		button.setFocusable(isFocus);
		return button;
	}
	//专门产生按钮                     文本显示  命令  监听器  是否显焦
	public JButton createJButton(String text,String command,ImageIcon icon,int width,int height,ActionListener al,boolean isFocus){
		JButton button=new JButton(text,icon);
		button.setActionCommand(command);//设置动作
		button.setPreferredSize(new Dimension(width,height));
		button.addActionListener(al);//添加事件监听
		button.setFocusable(isFocus);
		return button;
	}
	//专门产生按钮                     带图片
	public JButton createJButton(String text,ImageIcon icon, ImageIcon enterIcon,int height, int width,ActionListener al){
		JButton button=new JButton(text,icon);
		button.setRolloverIcon(enterIcon);
		button.setPreferredSize(new Dimension(width,height));
		button.addActionListener(al);//添加事件监听
		button.setContentAreaFilled(false); // 这一句非常重要, 否则父类还会绘制按钮的区域. 
		button.setFocusable(false);
		return button;
	}
	
	//生成文本框   默认文本  文本框大小长 是否可编辑
	public JTextField createJTextField(String text,int cols,boolean isEditable){
		JTextField field=new JTextField(text,cols);
		field.setEditable(isEditable);
		return field;
	}
	//生成文本框   默认文本  文本框大小长 是否可编辑  设置字体
	public JTextField createJTextField(String text,int cols,boolean isEditable,Font f){
		JTextField field=new JTextField(text,cols);
		field.setEditable(isEditable);
		field.setFont(f);
		return field;
	}
	//生成文本域    默认文本  列数  行数  是否可编辑
	public JTextArea createJTextArea(String text,int cols,int rows,boolean isEditable,boolean lineWrap,boolean wrapStyleWord){
		JTextArea area=new JTextArea(text,cols,rows);
		area.setEditable(isEditable);
		area.setLineWrap(lineWrap);
		area.setWrapStyleWord(wrapStyleWord);
		return area;
	}
	//生成文本域    默认文本  列数  行数  是否可编辑  设置字体 
	public JTextArea createJTextArea(String text,int cols,int rows,boolean isEditable,boolean lineWrap,boolean wrapStyleWord,Font f){
		JTextArea area=new JTextArea(text,cols,rows);
		area.setEditable(isEditable);
		area.setFont(f);
		area.setLineWrap(lineWrap);
		area.setWrapStyleWord(wrapStyleWord);
		return area;
	}
	//生成文本域    默认文本  列数  行数  是否可编辑  设置字体  背景颜色  前景颜色
	public JTextArea createJTextArea(String text,int cols,int rows,boolean isEditable,Font f,boolean lineWrap,boolean wrapStyleWord,Color background, Color foreground){
		JTextArea area=new JTextArea(text,cols,rows);
		area.setEditable(isEditable);
		area.setFont(f);
		area.setLineWrap(lineWrap);
		area.setWrapStyleWord(wrapStyleWord);
		area.setBackground(background);
		area.setForeground(foreground);
		return area;
	}
	//产生一个滚动面板
	public JScrollPane createJScrollPane(Container c){
		JScrollPane sc=new JScrollPane(c);
		sc.setOpaque(false);
		sc.getViewport().setOpaque(false);  
		return sc;
	}
	//产生一个指定垂直和水平滚动策略的滚动面板  水平滚动策略  垂直滚动策略
	public JScrollPane createJScrollPane(Container c,int horizontal_policy,int vertical_policy){
		JScrollPane sc=new JScrollPane();
		sc.setHorizontalScrollBarPolicy(horizontal_policy);
		sc.setVerticalScrollBarPolicy(vertical_policy);
		return sc;
	}
	//设置框架属性                    传入的框架  关闭策略  x,y,width,height 
	public void setJFrameAttributes(JFrame f,String title,int close_policy,int x,int y,int width,int height,boolean isResizable){
		f.setTitle(title);
		f.setDefaultCloseOperation(close_policy);
		f.setLocation(x,y);
		f.setSize(width,height);
		f.setResizable(isResizable);
	}
	
	//设置框架属性                    传入的框架  关闭策略  x,y,width,height 
	public void setJFrameAttributes(JFrame f,String title,int close_policy,int x,int y,int width,int height,boolean isResizable,WindowListener wl){
		f.setTitle(title);
		f.setDefaultCloseOperation(close_policy);
		f.setLocation(x,y);
		f.setSize(width,height);
		f.setResizable(isResizable);
		f.addWindowListener(wl);
	}
	//产生一条列表组件   条目宽度
	public JList createJList(int cell_width){
		JList list=new JList();
		list.setFixedCellWidth(cell_width);
		return list;
	}
	//产生一条列表组件   条目宽度  列表选择监听器
	public JList createJList(int cell_width,ListSelectionListener lsl){
		JList list=new JList();
		list.setFixedCellWidth(cell_width);
		list.addListSelectionListener(lsl);
		return list;
	}
	//产生一条列表组件   条目宽度  条目间距  源数据
	public JList createJList(int cell_width,int cell_height,Vector<Object> v,ListSelectionListener lsl){
		JList list=new JList(v);
		list.setFixedCellWidth(cell_width);
		list.setFixedCellHeight(cell_height);
		list.addListSelectionListener(lsl);
		return list;
	}
	//产生一条列表组件   条目宽度  条目间距  源数据
	public JList createJList(int cell_width,int cell_height,Object[] data,ListSelectionListener lsl){
		JList list=new JList(data);
		list.setFixedCellWidth(cell_width);
		list.setFixedCellHeight(cell_height);
		list.addListSelectionListener(lsl);
		return list;
	}
	//获得一个具有BorderLayout布局的面板
	public JPanel createBorderJPanel(){
		JPanel p=new JPanel();
		p.setOpaque(false);
		p.setLayout(new BorderLayout());
		return p;
	}
	//获得一个具有BorderLayout布局的面板
	public JPanel createBorderJPanel(int row_distance,int col_distance){
		JPanel p=new JPanel();
		p.setOpaque(false);
		p.setLayout(new BorderLayout(row_distance,col_distance));
		return p;
	}
	//获得一个具有GridLayout布局的面板  指定行数，列数，行距，列距
	public JPanel createGridJPanel(int rows,int cols,int col_distance,int row_distance){
		JPanel p=new JPanel();
		p.setLayout(new GridLayout(rows,cols,col_distance,row_distance));
		return p;
	}
	//获得一个具有GridLayout布局的面板
	public JPanel createGridJPanel(int rows,int cols){
		JPanel p=new JPanel();
		p.setOpaque(false);
		p.setLayout(new GridLayout(rows,cols));
		return p;
	}
	//获得一个具有卡片布局的面板
	public JPanel createCardJPanel(CardLayout card){
		JPanel p=new JPanel();
		p.setOpaque(false);
		p.setLayout(card);
		return p;
	}
	//获得一个具有绝对布局的的面板
	public JPanel createAbsoluteJPanel(){
		JPanel p=new JPanel();
		p.setOpaque(false);
		p.setLayout(null);
		return p;
	}
	//获得一个具有FlowLayout流式布局的面板
	public JPanel createFlowJPanel(){
		JPanel p=new JPanel();
		p.setOpaque(false);
		p.setLayout(new FlowLayout());
		return p;
	}
	//获得一个具有FlowLayout流式布局的面板
	public JPanel createBoxJPanel(int type){
		JPanel p=new JPanel();
		p.setOpaque(false);
		BoxLayout boxLayout=new BoxLayout(p, type);
		p.setLayout(boxLayout);
		return p;
	}
//	//获得一个具有卡片布局的面板
//	public JPanel createCardJPanel(CardLayout card){
//		JPanel p=new JPanel();
//		p.setLayout(card);
//		return p;
//	}
//	//获得一个具有绝对布局的的面板
//	public JPanel createAbsoluteJPanel(){
//		JPanel p=new JPanel();
//		p.setLayout(null);
//		return p;
//	}
	//获得一个具有FlowLayout流式布局的面板
	public JPanel createFlowJPanel(int policy,int col_distance,int row_distance){
		JPanel p=new JPanel();
		p.setOpaque(false);
		p.setLayout(new FlowLayout( policy, col_distance, row_distance));
		return p;
	}
	//获得一个具有FlowLayout流式布局的面板  指定左右对齐方式
	public JPanel createFlowJPanel(int leftOrRight_policy){
		JPanel p=new JPanel();
		p.setOpaque(false);
		p.setLayout(new FlowLayout(leftOrRight_policy));
		return p;
	}
	
	//获得一个具有FlowLayout流式布局的面板  指定左右对齐方式
	public JPanel createFlowJPanel(int leftOrRight_policy, Color bgColor){
		JPanel p=new JPanel();
		p.setOpaque(false);
		p.setLayout(new FlowLayout(leftOrRight_policy));
		p.setBackground(bgColor);
		return p;
	}
		
	//获得一个带有监听器的菜单选项
	public JMenuItem createJMenuItem(String text,String command,ActionListener al){
		JMenuItem item=new JMenuItem(text);
		item.addActionListener(al);
		item.setActionCommand(command);
		return item;
	}
	//获得一个JRadioButton按钮
	public JRadioButton createJRadioButton(){
		JRadioButton jrb=new JRadioButton();
		return jrb;
	}
	//获得一个带ItemListener监听器的JRadioButton按钮
	public JRadioButton createJRadioButton(ItemListener il){
		JRadioButton jrb=new JRadioButton();
		jrb.addItemListener(il);
		return jrb;
	}
	//获得一个复选框
	public JCheckBox createJCheckBox(){
		JCheckBox box=new JCheckBox();
		return box;
	}
	//获得一个复选框
	public JCheckBox createJCheckBox(String text, boolean isSelect){
		JCheckBox box=new JCheckBox(text);
		box.setSelected(isSelect);
		box.setOpaque(false);
		return box;
	}
	//获得一个下拉列表框
	public JComboBox createJComboBox(String[] data){
		JComboBox box=new JComboBox(data);
		return box;
	}
	//获得一个下拉列表框
	public JComboBox createJComboBox(Vector<Object> data){
		JComboBox box=new JComboBox(data);
		return box;
	}
	//获得一个下拉列表框
	public JComboBox createJComboBox(String[] data,int width,int height){
		JComboBox box=new JComboBox(data);
		box.setPreferredSize(new Dimension(width,height));
		return box;
	}
	//获得一个下拉列表框
	public JComboBox createJComboBox(Vector<Object> data,int width,int height){
		JComboBox box=new JComboBox(data);
		box.setPreferredSize(new Dimension(width,height));
		return box;
	}
	//获得一个带ItemListener的下拉列表框
	public JComboBox createJComboBox(Vector<Object> data,ItemListener il){
		JComboBox box=new JComboBox(data);
		box.addItemListener(il);
		return box;
	}
	//获得一个带ItemListener的下拉列表框
	public JComboBox createJComboBox(String[] data,ItemListener il){
		JComboBox box=new JComboBox(data);
		box.addItemListener(il);
		return box;
	}
	//获得一个带ItemListener的下拉列表框
	public JComboBox createJComboBox(Vector<Object> data,int width,int height,ItemListener il){
		JComboBox box=new JComboBox(data);
		box.setMaximumSize(new Dimension(width,height));
		box.setMinimumSize(new Dimension(width,height));
		box.addItemListener(il);
		return box;
	}
	//获得一个带ItemListener的下拉列表框
	public JComboBox createJComboBox(String[] data,int width,int height,ItemListener il){
		JComboBox box=new JComboBox(data);
		box.setMaximumSize(new Dimension(width,height));
		box.setMinimumSize(new Dimension(width,height));
		box.addItemListener(il);
		return box;
	}
	//产生一个选项卡面板
	public JTabbedPane createJTabbedPane(){
		JTabbedPane tab=new JTabbedPane();
		return tab;
	}
	//产生一个指定位置的选项卡面板
	public JTabbedPane createJTabbedPane(int pos){
		JTabbedPane tab=new JTabbedPane(pos);
		return tab;
	}
	//产生一个带ChangeListener的选项卡面板
	public JTabbedPane createJTabbedPane(ChangeListener cl){
		JTabbedPane tab=new JTabbedPane();
		tab.addChangeListener(cl);
		return tab;
	}
	//产生一个是否可以浮动的工具栏
	public JToolBar createJToolBar(boolean isFloatable){
		JToolBar bar =new JToolBar();
		bar.setFloatable(isFloatable);
		return bar;
	}
	//产生一个JTextPane面板
	public JTextPane createJTextPane(boolean isEditable){
		JTextPane p=new JTextPane();
		p.setEditable(isEditable);
		return p;
	}
	//产生一个JTextPane面板
	public JTextPane createJTextPane(boolean isEditable,Color background,Color foreground){
		JTextPane p=new JTextPane();
		p.setEditable(isEditable);
		p.setBackground(background);
		p.setForeground(foreground);
		return p;
	}
	//产生一个进度条
	public JProgressBar createJProgressBar(int min,int max,int value,boolean stringPainted,boolean borderPainted){
		JProgressBar bar=new JProgressBar();
		bar.setMinimum(min);
		bar.setMaximum(max);
		bar.setBorderPainted(borderPainted);
		bar.setStringPainted(stringPainted);
		bar.setValue(value);
		return bar;
	}
	//产生一个指定大小的进度条
	public JProgressBar createJProgressBar(int min,int max,int value,boolean stringPainted,boolean borderPainted,Dimension d){
		JProgressBar bar=new JProgressBar();
		bar.setMinimum(min);
		bar.setMaximum(max);
		bar.setBorderPainted(borderPainted);
		bar.setStringPainted(stringPainted);
		bar.setValue(value);
		bar.setPreferredSize(d);
		return bar;
	}
	//产生一个分隔面板                       分隔面板1  分隔面板2   水平或垂直分割  分割条位置   分割条宽度  是否可收起
	public JSplitPane createJSplitPane(Container c1,Container c2,int horizontalOrVertical,int dividerLoaction,int dividerSize,boolean expandable){
		JSplitPane splitPane=new JSplitPane(horizontalOrVertical,
                true,c1,c2);
		splitPane.setDividerLocation(dividerLoaction);
		splitPane.setOneTouchExpandable(expandable);
		splitPane.setDividerSize(dividerSize);
		return splitPane;
	}
	//产生一个JToggleButton
	public JToggleButton createJToggleButton(String text,String command,Icon icon,int width,int height,ActionListener al, boolean selected){
		JToggleButton button=new JToggleButton(text,icon,selected);
		button.setActionCommand(command);
		button.addActionListener(al);
		button.setPreferredSize(new Dimension(width,height));
		return button;
	}
	//产生一个JToggleButton
	public JToggleButton createJToggleButton(String text,String command,Icon icon,int width,int height,ActionListener al){
		JToggleButton button=new JToggleButton(text,icon);
		button.setActionCommand(command);
		button.addActionListener(al);
		button.setPreferredSize(new Dimension(width,height));
		return button;
	}
	//产生将组件结合起来的面板
	public JPanel createJPanelWithComponents(JLabel label,Container field,int policy){
		JPanel p=this.createFlowJPanel(policy);
		p.add(label);
		p.add(field);
		return p;
	}
	//产生将两个面板整合起来的面板
	public JPanel createJPanelWithComponents(Container c1,Container c2,int policy){
		JPanel p=this.createFlowJPanel(policy,0,0);
		p.add(c1);
		p.add(c2);
		return p;
	}
	//产生将三个面板整合起来的面板
	public JPanel createJPanelWithComponents(Container c1,Container c2,Container c3,int policy){
		JPanel p=this.createFlowJPanel(policy,0,0);
		p.add(c1);
		p.add(c2);
		p.add(c3);
		return p;
	}
	//产生将四个面板整合起来的面板
	public JPanel createJPanelWithComponents(Container c1,Container c2,Container c3,Container c4,int policy){
		JPanel p=this.createFlowJPanel(policy,0,0);
		p.add(c1);
		p.add(c2);
		p.add(c3);
		p.add(c4);
		return p;
	}
	//产生一个普通表格
	public JTable createJTable(){
		JTable table=new JTable();
		return table;
	}
	//产生一个普通表格
	public JTable createJTable(AbstractTableModel model,MouseMotionListener mm,MouseListener ml,int rowHeight,int align){
		JTable table=new JTable(model);
		table.addMouseMotionListener(mm);
		table.addMouseListener(ml);
		table.setRowHeight(rowHeight);
		table.getTableHeader().setReorderingAllowed(false); 
		//表格剧中
		DefaultTableCellRenderer   defaultTableCellRenderer   =   new   DefaultTableCellRenderer();   
		defaultTableCellRenderer.setHorizontalAlignment(align);   
		table.setDefaultRenderer(Object.class,defaultTableCellRenderer);
		return table;
	}
	//产生一个带AbstractTableModel的表格
	public JTable createJTable(AbstractTableModel model){
		JTable table=new JTable(model);
		return table;
	}
	//产生一个密码框
	//生成文本框   默认文本  文本框大小长 是否可编辑
	public JPasswordField createJPasswordField(String text,int cols,boolean isEditable){
		JPasswordField field=new JPasswordField(text,cols);
		field.setEditable(isEditable);
		return field;
	}
 
	//产生一个带监听器的菜单项
	public MenuItem createMenuItem(String text,ActionListener al){
		MenuItem mi=new MenuItem(text);
		mi.addActionListener(al);
		return mi;
	}
	//产生一个带监听器的菜单项
	public MenuItem createMenuItem(String text,String command,ActionListener al){
		MenuItem mi=new MenuItem(text);
		mi.setActionCommand(command);
		mi.addActionListener(al);
		return mi;
	}
	//显示一个对话框窗口，用户可以从中选择文件
	public FileDialog createFileDialog(JFrame parent, String title, int mode) {
		FileDialog d = new FileDialog(parent,title,mode);
		return d;	
	}
	/**======================================另外一种创建方式============================================*/
	public JButton createRPJButton(String text,Icon icon,Icon rolloverIcon,ActionListener action){
		RPJButton jb=new RPJButton(text);
		jb.setIcon(icon);
		jb.setRolloverIcon(rolloverIcon);
		jb.setFocusPainted(false);
		jb.setBorderPainted(false);
		jb.setContentAreaFilled(false);
		jb.setHorizontalTextPosition(SwingConstants.CENTER);
		jb.setVerticalTextPosition(SwingConstants.BOTTOM);
		jb.addActionListener(action);
		jb.setCursor(new Cursor(Cursor.HAND_CURSOR));
		return jb;
	}
	/**======================================另外一种创建方式============================================*/
	public JToggleButton createRPToolBarJButton(String text,Icon icon,Icon rolloverIcon,int horizontalText,int verticalText,ActionListener action){
		JToggleButton jb=new RPToolBarJButton(text);
		jb.setIcon(icon);
		jb.setRolloverIcon(rolloverIcon);
//		jb.setPressedIcon(pressedIcon);
//		jb.setSelectedIcon(rolloverIcon);
//		jb.setRolloverSelectedIcon(pressedIcon) ;
		jb.setHorizontalTextPosition(SwingConstants.CENTER);
		jb.setVerticalTextPosition(SwingConstants.BOTTOM);
//		jb.setHorizontalAlignment(SwingConstants.CENTER);
//		jb.setVerticalTextPosition(SwingConstants.BOTTOM);
		jb.setFocusPainted(false);
		jb.setBorderPainted(false);
		jb.setContentAreaFilled(false);
		jb.addActionListener(action);
		jb.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jb.setMargin(new Insets(-5, 0, 5, 0));
//		if(action==null){
//			jb.setEnabled(false);
//		}
		return jb;
	}
	public JToggleButton createRPToolBarJButton(String text,Icon icon,Icon rolloverIcon,ActionListener action){
		JToggleButton jb=new RPToolBarJButton(text);
		jb.setIcon(icon);
		jb.setRolloverIcon(rolloverIcon);
//		jb.setPressedIcon(pressedIcon);
//		jb.setSelectedIcon(pressedIcon);
//		jb.setRolloverSelectedIcon(pressedIcon) ;
		jb.setFocusPainted(false);
		jb.setBorderPainted(false);
		jb.setContentAreaFilled(false);
		jb.addActionListener(action);
		jb.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jb.setMargin(new Insets(-8, 0, 8, 0));
//		if(action==null){
//			jb.setEnabled(false);
//		}
		return jb;
	}
	//产生一个普通表格
	public RPTable createRPJTable(AbstractTableModel model,MouseMotionListener mm,MouseListener ml,int rowHeight,int align){
		RPTable table=new RPTable(model);
		table.addMouseMotionListener(mm);
		table.addMouseListener(ml);
		table.setRowHeight(rowHeight);
		table.getTableHeader().setReorderingAllowed(false); 
		//表格剧中
		DefaultTableCellRenderer   defaultTableCellRenderer   =   new   DefaultTableCellRenderer();   
		defaultTableCellRenderer.setHorizontalAlignment(align);   
		table.setDefaultRenderer(Object.class,defaultTableCellRenderer);
		return table;
	}
	//产生一个普通表格
	public JTable createJTable(AbstractTableModel model, MouseListener ml,int rowHeight,int align){
		JTable table=new JTable(model);
		table.addMouseListener(ml);
		table.setRowHeight(rowHeight);
		table.getTableHeader().setReorderingAllowed(false); 
		//表格剧中
		DefaultTableCellRenderer   defaultTableCellRenderer   =   new   DefaultTableCellRenderer();   
		defaultTableCellRenderer.setHorizontalAlignment(align);   
		table.setDefaultRenderer(Object.class,defaultTableCellRenderer);
		return table;
	}
	
	public Border createTitledBorder(String title) {
		return new TitledBorder(null, title){
			private static final long serialVersionUID = 1L;
			@Override
			public void paintBorder(Component c, Graphics g, int x, int y,
					int width, int height) {
				g.setFont(new Font("宋体", Font.BOLD, 12));
				g.drawString(title, 10, 10);
			}
		};
	}
}
